﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media.Effects;
using System.IO;

namespace SStuff.MetaEffects.Compiler
{
    public enum ShaderProfile
    {
        ps_2_0,
        ps_3_0
    }
    public static class HlslCompiler
    {
        public static PixelShader Compile(string hlsl, ShaderProfile profile)
        {
            byte[] data = Native.NativeCompiler.CompileShader(hlsl, "main", profile.ToString());
            if (data == null)
                throw new InvalidOperationException("HLSL compilation failed");
            var ms = new MemoryStream(data);
            var shader = new PixelShader();
            shader.SetStreamSource(ms);
            return shader;
        }
    }
}
